package com.tiger.sso;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * 
 * @author andy
 *
 */
public class WhitelistFilter extends SpringConfigFilter {
	
	private Whitelist whitelist;

	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		if(whitelist != null && whitelist.match(request.getRemoteAddr())) {
			chain.doFilter(request, response);
		} else {
			super.doFilter(request, response, chain);
		}
	}

	public Whitelist getWhitelist() {
		return whitelist;
	}

	public void setWhitelist(Whitelist whitelist) {
		this.whitelist = whitelist;
	}
}
